﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Tisonet.Dobrak.Domain.Services.Downloaders;
using Tisonet.Dobrak.Domain.Services.Movies;

namespace Tisonet.Dobrak.Domain.Services.Tests.Movies
{
    [TestClass]
    public class CsfdApiMoviesProviderTests
    {
        [TestMethod]
        [DeploymentItem("Tisonet.Dobrak.Domain.Services.Tests\\Movies\\TestFiles\\Movies1.txt")]
        public void Can_Load_Movie_From_Stream()
        {
            var mock = new Mock<IDownloader>();
            mock.Setup(m => m.DownloadAsync(It.IsAny<Uri>())).ReturnsAsync(new FileStream("Movies1.txt", FileMode.Open));
            var provider = new CsfdApiMovieProvider(mock.Object);

            var result = provider.GetMovieAsync("").Result;

            Assert.IsNotNull(result);
            Assert.AreEqual("Terapie láskou", result.Name);
            Assert.AreEqual("2012", result.Year);
            Assert.AreEqual("10 minutes", result.Runtime);
        }
    }
}
